package com.yunhe.task.client.fallback;

import com.yunhe.task.client.EnergyClient;
import com.yunhe.common.model.DomainList;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.data.ElectricityDay;
import com.yunhe.common.model.data.ElectricityMonth;
import com.yunhe.common.util.FallbackUtil;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * @author liuronglei
 */
@Component
public class EnergyFallbackFactory implements FallbackFactory<EnergyClient> {
    @Override
    public EnergyClient create(Throwable arg0) {
        return new EnergyClient() {

            @Override
            public ResponseEntity<ResultObject> postDay(ElectricityDay electricity) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> postMonth(ElectricityMonth electricity) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> postDay(DomainList<ElectricityDay> domainList) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject> postMonth(DomainList<ElectricityMonth> domainList) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<List<ElectricityDay>>> searchDay(List<Date> dtime) {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
